#ifndef _HAL_USART_H
#define _HAL_USART_H
#include "main.h"
#include "LsdUARTBase.h"//当前文件主要任务串口相关驱动

typedef enum
{
	ANALOG_USART_NOR1    =  0,		//常温水1
	ANALOG_USART_NOR2		=  1,   	//常温水2	
	ANALOG_USART_NUM_MAX,
	
}teAnalogUsartNum;
#define COM_NONE_BIT_DEAL 	0
#define COM_START_BIT_DEAL 	1
#define COM_DATA_BIT_DEAL 	2
#define COM_CHECK_BIT_DEAL 	3
#define COM_STOP_BIT_DEAL 	4


#define NONE 0//没有校验

typedef enum
{
    TimeRecvStartStep1 = 0,
    TimeRecvStep2 = 1,
    TimeRecvStep3 = 2,
    TimeRecvStep1 = 3,
    TimeSendStep = 4,

} TimeStep;


typedef struct
{
	uint8_t  CheckType;			
	uint8_t  UartStat;      			//串口状态
	uint16_t UartMaxLength; 			//最大发送长度
	uint16_t Sendlength;    			//发送长度
	uint8_t  TxEn;								//发送使能
	uint8_t  RxEn;								//接收使能
	uint8_t  *UART_Send_buf;  		//发送缓存
	
	uint8_t ucRecvData ;         //每次接收的字节
	uint8_t ucAcquCx ;           //三次滤波计数
	uint8_t ucRecvBitCx ;        //接收位计数
	uint8_t ucSendBitCx ;        //发送位计数
	uint8_t ucSendLengCx ;       //发送长度计数
	uint8_t ucRecvBitBuff ;      //采集位保存
	
	GPIO_T*  PORT_RX_x;						//接收端口
	uint32_t GPIO_RX_x;						//接收引脚
	GPIO_T*  PORT_TX_x;						//发送端口
	uint32_t GPIO_TX_x;						//发送引脚
	TMR_T* 	 TMRx;								//定时器
	EINT_LINE_T   EINTx;										//中断位号	
}tsTypeUsart;

typedef struct
{
	UARTPortDef		UART_PROT_x;              //事件号
	GPIO_T*  			PORT_RX_x;								//接收端口
	uint32_t 			GPIO_RX_x;								//接收引脚
	GPIO_T*  			PORT_TX_x;								//发送端口
	uint32_t 			GPIO_TX_x;								//发送引脚
	TMR_T* 			  TMRx;											//对应的定时器
	EINT_LINE_T   EINTx;										//中断位号							
	
}tsTypeUsartPin;



extern void HAL_UART_Receive_DMA(UARTPortDef port, uint8_t *tbuff, uint16_t tlen);
extern void HAL_UART_Transmit_DMA(UARTPortDef port, uint8_t *tbuff, uint16_t tlen);
extern void OnHalUARTInit(uint32_t BaudRate); //模拟串口初始化
extern void OnHalUSARTTest(void);
extern void HAL_ATIM_ANALOG_USARTCallback(UARTPortDef port);
extern void OnAnalogUsartRx(UARTPortDef port);
#endif

